// 云函数入口文件
const cloud = require('wx-server-sdk')
var request = require('request')

cloud.init({
  env:"tfjkp-0ge80vu9ea710148"
})


// 云函数入口函数
exports.main = async (event, context) => {
  var url = "";
  if(event.serverUrl === "serverUrl"){
    url = "http://mqtt.natapp1.cc/gzh/api/getDeptList";
  }  
  //qz
  return new Promise((resolve, reject) => {
    request({
      url: url,
      method: "GET",//GET
      json: true,
      headers: {
        "content-type": "application/json",
      },
    }, function (error, response, body) {
        console.log(body)
      if (!error && response.statusCode == 200) {
        try {
          resolve(body)
        } catch (e) {
          reject()
        }
      }
    })
  })
}